<script type="text/javascript">
	function onlyNumbers(evt) 
	{
		evt = (evt) ? evt : window.event
		var charCode = (evt.which) ? evt.which : evt.keyCode
		if (charCode > 31 && (charCode < 48 || charCode > 57)) {
			//status = "This field accepts numbers only."
			alert("Harus di Isi Angka");
			return false
		}
		//status = ""
		return true 	
	}
</script>
<form method="post" name="frmSearch" action="<?php echo site_url('masterbarangdetailcontroller');?>">
    <table width="100%" cellpadding="3" cellspacing="0" border="1">
        <tr>
            <td width="152"><strong>Pilih Search</strong></td>
            <td width="16" align="center"><strong>:</strong></td>
            <td width="803" colspan="3">
                <select name="kdbrgview">
                    <option value="0">Pilih</option>
                    <option value="1">Kode Barang</option>
                    <option value="2">Nama Barang</option>
                </select> &nbsp;|&nbsp;<input type="text"  name="brgview" id="brgview" size="50" />&nbsp;|&nbsp;<input type="submit" name="btnview" value="Search">
            </td>
            <?php if(count($kdbrgheader)>0){ ?>
        	{kdbrgheader}
        	<input type="hidden"  name="kdbrngview" id="kdbrngview" maxlength="12" size="25" value="{KodeBarang}" readonly="readonly"/>
        	{/kdbrgheader}
    		<?php } ?>
		</tr>
    </table>
</form>
<br />
<form method="post" name="frmSave" action="<?php echo site_url('masterbarangdetailcontroller/tambahmasterbarang');?>">
    <table width="100%" cellpadding="3" cellspacing="0" border="1">
    	<tr style="background-color:#FFF; color:#000000;" align="center">
        	<td colspan="3" height="25"><strong>INPUT DAFTER BARANG DETAIL</strong></td>
    	</tr>
        <tr >
        	<td colspan="3" height="25">&nbsp;</td>
    	</tr>
        <?php if(count($kdbrgheader)>0){ ?>
        {kdbrgheader}
        <tr>
            <td width="149"><strong>Kode Barang</strong></td>
            <td width="20" align="center"><strong>:</strong></td>
            <td width="762" colspan="3"><input type="text"  name="kdbrng" id="kdbrng" maxlength="12" size="25" value="{KodeBarang}" readonly="readonly"/></td>
        </tr>
        {/kdbrgheader}
    	<?php } ?>
        <tr>
            <td width="149"><strong>Kode Barang Detail</strong></td>
            <td width="20" align="center"><strong>:</strong></td>
            <td width="762" colspan="3"><input type="text"  name="kdbrngdet" id="kdbrngdet" maxlength="20" size="25"/></td>
        </tr>
        <tr>
            <td width="149"><strong>Nama Barang</strong></td>
            <td width="20" align="center"><strong>:</strong></td>
            <td ><input type="text"  name="nmbrng" id="nmbrng" maxlength="100" size="50" /></td>
        </tr>
        <tr>
            <td width="149"><strong>Keterangan</strong></td>
            <td width="20" align="center"><strong>:</strong></td>
            <td ><input type="text"  name="description" id="description" size="50" maxlength="100"/></td>
        </tr>
        <tr>
            <td width="149"><strong>Harga</strong></td>
            <td width="20" align="center"><strong>:</strong></td>
            <td ><input type="text"  name="itmprice" id="itmprice" size="50" maxlength="15" onkeypress="return onlyNumbers(event);"/></td>
        </tr>
        <tr>
            <td width="149"><strong>Tipe Unit</strong></td>
            <td width="20" align="center"><strong>:</strong></td>
            <td>
            	<select name="tpunit">
                	<option value="">--Pilih--</option>
                    <option value="BTG">Batang</option>
                    <option value="DUS">Dus</option>
                    <option value="LBR">Lembar</option>
                    <option value="PCS">Pcs</option>
                    <option value="ROLL">Roll</option>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="3" align="center"><input type="submit" value="Save" name="btnSave" >&nbsp;<a href="<?php echo site_url('masterbarangcontroller');?>">BACK</a></td>
        </tr>
    </table>
</form>
<br />
<br />
<div class="cleaner_h10"></div>
<table border="1" cellpadding="3" cellspacing="0" width="100%" style=" border-collapse: collapse;" class="record" bordercolor="#CCCCCC">
    <tr style="background-color:#FFF; color:#000000" align="center">
        <td colspan="7" height="25"><strong>LIST DETAIL BARANG</strong></td>
    </tr>
    <tr style="background-color:#333; color:#FFF;" align="center">
        <td>Kode Barang</td>
        <td>Kode Barang Detail</td>
        <td>Nama Barang</td>
        <td>Keterangan</td>
        <td>Harga</td>
        <td>Tipe Unit</td>
        <td>Action</td>
    </tr>
	<?php $i=0;if(count($mstrbarangdet)>0){ ?>
        {mstrbarangdet}
            <tr class="cellDefault">
                <td align="center">{KodeBarang}</td>
                <td align="center">{KodeDetailBarang}</td>
                <td align="center">{Productname}</td>
                <td align="left">{Description}</td>
                <td align="center">{Itemprice}</td>
                <td align="center">{Typeunit}</td>
                <td align="center">
                	<button onclick="javascript:window.location='<?php echo site_url('masterbarangdetailcontroller/ubahdetailbarang');?>/{KodeDetailBarang}';" id="edit">Edit</button>
                    <?Php 
						if($this->session->userdata('grade') == 0)
						{
					?>
							&nbsp;|&nbsp;
                            <button id="hapus" onclick="javascript:window.location='<?php echo site_url('masterbarangdetailcontroller/deletedetailbarang');?>/{KodeDetailBarang}/{KodeBarang}';">Hapus</button>
					<?php } ?>
				</td>
            </tr>
            <?php $i++?>
        {/mstrbarangdet}
    <?php } else{
            echo "<tr>";
            echo "<td colspan='9' style='text-align:center;color:red;'>No Data To Display</td>";
            echo "</tr>";
    } ?>
    <?php if(!empty($message))?>{message}
</table>
<?php //echo $links; ?>